package main

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"github.com/yyangl/yoyo/application"
	"github.com/yyangl/yoyo/middlwares"
	"github.com/yyangl/yoyo/module/admin/v1"
	v2 "github.com/yyangl/yoyo/module/admin/v2"
	"github.com/yyangl/yoyo/utils"
)

func main() {
	engine := gin.Default()
	//register, err := etcd.NewEtcdRegister(registry.DefaultAddr)
	//if err != nil {
	//	fmt.Printf("application run error.")
	//}
	engine.Use(middlwares.CorsMiddleware())
	app := &application.Application{}
	app.SetAddr(":8090")
	app.SetEngine(engine)
	app.SetVersion("0.0.1")
	//app.SetRegister(register)
	app.SetServiceKey(utils.ResolveServiceRootKey())
	application.Register(&v1.Admin{Version: "v1"})
	application.Register(&v2.Admin{Version: "v2"})
	if err := app.Run(); err != nil {
		fmt.Printf("app run error.err = %v", err)
	}
}
